"""


"""
import time

from django.conf import settings
from django.core.mail import send_mail
from celery_tasks.main import app


@app.task(bind=True, name='email_sender')
def email_sender(self, verify_url, email):

    try:
        # 验证都通过后发送邮件
        time.sleep(5)
        result = send_mail(subject="python", message="您的邮箱验证链接为:\n%s" % verify_url, from_email=settings.EMAIL_FROM, recipient_list=[email])

    except Exception as e:
        result = -1

    else:
        print("邮件发送成功...")

    if result == -1:
        self.retry(countdown=15, max_retries=3, exc=Exception("邮件发送失败了..."))
